import 'package:flutter/material.dart';

class TabbarControllerPage extends StatefulWidget {
  TabbarControllerPage({Key key}) : super(key: key);

  @override
  _TabbarControllerPageState createState() => _TabbarControllerPageState();
}

class _TabbarControllerPageState extends State<TabbarControllerPage>
    with SingleTickerProviderStateMixin {
  TabController tabController;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    tabController = new TabController(length: 3, vsync: this);
    tabController.addListener(() {
      print(tabController.index);
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("data"),
        bottom: TabBar(
          controller: this.tabController,
          tabs: <Widget>[
            Tab(
              text: "热门",
            ),
            Tab(
              text: "关注",
            ),
            Tab(
              text: "附近",
            )
          ],
        ),
      ),
      body: TabBarView(
        controller: this.tabController,
        children: <Widget>[
          Center(
            child: Text("我的"),
          ),
          Center(
            child: Text("点赞的"),
          ),
          Center(
            child: Text("我喜欢的"),
          )
        ],
      ),
    );
  }
}
